mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Added language option. Closes #336.
This commit is contained in:
parent
0ecc4b5966
commit
41b89de83f
7 changed files with 197 additions and 97 deletions
|
@ -20,7 +20,7 @@ void lcPreferences::LoadDefaults()
|
|||
mDrawAxes = lcGetProfileInt(LC_PROFILE_DRAW_AXES);
|
||||
mDrawEdgeLines = lcGetProfileInt(LC_PROFILE_DRAW_EDGE_LINES);
|
||||
mLineWidth = lcGetProfileFloat(LC_PROFILE_LINE_WIDTH);
|
||||
mAllowLOD = lcGetProfileFloat(LC_PROFILE_ALLOW_LOD);
|
||||
mAllowLOD = lcGetProfileInt(LC_PROFILE_ALLOW_LOD);
|
||||
mDrawGridStuds = lcGetProfileInt(LC_PROFILE_GRID_STUDS);
|
||||
mGridStudColor = lcGetProfileInt(LC_PROFILE_GRID_STUD_COLOR);
|
||||
mDrawGridLines = lcGetProfileInt(LC_PROFILE_GRID_LINES);
|
||||
|
@ -669,6 +669,7 @@ void lcApplication::ShowPreferencesDialog()
|
|||
Options.POVRayPath = lcGetProfileString(LC_PROFILE_POVRAY_PATH);
|
||||
Options.LGEOPath = lcGetProfileString(LC_PROFILE_POVRAY_LGEO_PATH);
|
||||
Options.DefaultAuthor = lcGetProfileString(LC_PROFILE_DEFAULT_AUTHOR_NAME);
|
||||
Options.Language = lcGetProfileString(LC_PROFILE_LANGUAGE);
|
||||
Options.CheckForUpdates = lcGetProfileInt(LC_PROFILE_CHECK_UPDATES);
|
||||
|
||||
Options.AASamples = CurrentAASamples;
|
||||
|
@ -689,6 +690,7 @@ void lcApplication::ShowPreferencesDialog()
|
|||
if (Dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
bool LanguageChanged = Options.Language != lcGetProfileString(LC_PROFILE_LANGUAGE);
|
||||
bool LibraryChanged = Options.LibraryPath != lcGetProfileString(LC_PROFILE_PARTS_LIBRARY);
|
||||
bool ColorsChanged = Options.ColorConfigPath != lcGetProfileString(LC_PROFILE_COLOR_CONFIG);
|
||||
bool AAChanged = CurrentAASamples != Options.AASamples;
|
||||
|
@ -704,11 +706,12 @@ void lcApplication::ShowPreferencesDialog()
|
|||
lcSetProfileString(LC_PROFILE_MINIFIG_SETTINGS, Options.MinifigSettingsPath);
|
||||
lcSetProfileString(LC_PROFILE_POVRAY_PATH, Options.POVRayPath);
|
||||
lcSetProfileString(LC_PROFILE_POVRAY_LGEO_PATH, Options.LGEOPath);
|
||||
lcSetProfileString(LC_PROFILE_LANGUAGE, Options.Language);
|
||||
lcSetProfileInt(LC_PROFILE_CHECK_UPDATES, Options.CheckForUpdates);
|
||||
lcSetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES, Options.AASamples);
|
||||
lcSetProfileInt(LC_PROFILE_STUD_LOGO, Options.StudLogo);
|
||||
|
||||
if (LibraryChanged || ColorsChanged || AAChanged)
|
||||
if (LanguageChanged || LibraryChanged || ColorsChanged || AAChanged)
|
||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Some changes will only take effect the next time you start LeoCAD."));
|
||||
|
||||
if (Options.CategoriesModified)
|
||||
|
|
|
@ -26,6 +26,7 @@ struct lcPreferencesDialogOptions
|
|||
QString POVRayPath;
|
||||
QString LGEOPath;
|
||||
QString DefaultAuthor;
|
||||
QString Language;
|
||||
int CheckForUpdates;
|
||||
|
||||
int AASamples;
|
||||
|
|
|
@ -73,6 +73,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
|
|||
lcProfileEntry("Settings", "ViewSphereTextColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_VIEW_SPHERE_TEXT_COLOR
|
||||
lcProfileEntry("Settings", "ViewSphereHighlightColor", LC_RGBA(255, 0, 0, 255)), // LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR
|
||||
|
||||
lcProfileEntry("Settings", "Language", ""), // LC_PROFILE_LANGUAGE
|
||||
lcProfileEntry("Settings", "CheckUpdates", 1), // LC_PROFILE_CHECK_UPDATES
|
||||
lcProfileEntry("Settings", "ProjectsPath", ""), // LC_PROFILE_PROJECTS_PATH
|
||||
lcProfileEntry("Settings", "PartsLibrary", ""), // LC_PROFILE_PARTS_LIBRARY
|
||||
|
|
|
@ -21,6 +21,7 @@ enum LC_PROFILE_KEY
|
|||
LC_PROFILE_VIEW_SPHERE_TEXT_COLOR,
|
||||
LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR,
|
||||
|
||||
LC_PROFILE_LANGUAGE,
|
||||
LC_PROFILE_CHECK_UPDATES,
|
||||
LC_PROFILE_PROJECTS_PATH,
|
||||
LC_PROFILE_PARTS_LIBRARY,
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
#include "lc_glextensions.h"
|
||||
#include "pieceinf.h"
|
||||
|
||||
static const char* gLanguageLocales[] =
|
||||
{
|
||||
"", "de_DE", "en_US", "fr_FR", "pt_PT"
|
||||
};
|
||||
|
||||
lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogOptions* Options)
|
||||
: QDialog(Parent), mOptions(Options), ui(new Ui::lcQPreferencesDialog)
|
||||
{
|
||||
|
@ -41,6 +46,14 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
|
|||
ui->lgeoPath->setText(mOptions->LGEOPath);
|
||||
ui->authorName->setText(mOptions->DefaultAuthor);
|
||||
ui->mouseSensitivity->setValue(mOptions->Preferences.mMouseSensitivity);
|
||||
for (unsigned int LanguageIdx = 0; LanguageIdx < sizeof(gLanguageLocales) / sizeof(gLanguageLocales[0]); LanguageIdx++)
|
||||
{
|
||||
if (mOptions->Language == gLanguageLocales[LanguageIdx])
|
||||
{
|
||||
ui->Language->setCurrentIndex(LanguageIdx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->checkForUpdates->setCurrentIndex(mOptions->CheckForUpdates);
|
||||
ui->fixedDirectionKeys->setChecked(mOptions->Preferences.mFixedAxes);
|
||||
ui->autoLoadMostRecent->setChecked(mOptions->Preferences.mAutoLoadMostRecent);
|
||||
|
@ -153,6 +166,12 @@ void lcQPreferencesDialog::accept()
|
|||
mOptions->LGEOPath = ui->lgeoPath->text();
|
||||
mOptions->DefaultAuthor = ui->authorName->text();
|
||||
mOptions->Preferences.mMouseSensitivity = ui->mouseSensitivity->value();
|
||||
|
||||
int Language = ui->Language->currentIndex();
|
||||
if (Language < 0 || Language > sizeof(gLanguageLocales) / sizeof(gLanguageLocales[0]))
|
||||
Language = 0;
|
||||
mOptions->Language = gLanguageLocales[Language];
|
||||
|
||||
mOptions->CheckForUpdates = ui->checkForUpdates->currentIndex();
|
||||
mOptions->Preferences.mFixedAxes = ui->fixedDirectionKeys->isChecked();
|
||||
mOptions->Preferences.mAutoLoadMostRecent = ui->autoLoadMostRecent->isChecked();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>598</width>
|
||||
<height>450</height>
|
||||
<height>454</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -27,7 +27,97 @@
|
|||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="ApplicationGroup">
|
||||
<property name="title">
|
||||
<string>Application</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>Language</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Check for updates:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkForUpdates</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="Language">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Deutsch </string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>English</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Français</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Português</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="checkForUpdates">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Never</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Once a day</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Once a week</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Default author name:</string>
|
||||
|
@ -37,46 +127,17 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="authorName"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Check for updates:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkForUpdates</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="checkForUpdates">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Never</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Once a day</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Once a week</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="fixedDirectionKeys">
|
||||
<property name="text">
|
||||
<string>Fixed direction keys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="autoLoadMostRecent">
|
||||
<property name="text">
|
||||
<string>Open most recent file on startup</string>
|
||||
|
@ -84,7 +145,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<widget class="QGroupBox" name="CustomPathsGroup">
|
||||
<property name="title">
|
||||
<string>Custom Paths</string>
|
||||
</property>
|
||||
|
@ -99,40 +160,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="povrayLabel">
|
||||
<property name="text">
|
||||
<string>PO&V-Ray Executable:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>povrayExecutable</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>&LGEO Library:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lgeoPath</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lgeoPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="lgeoPathBrowse">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
|
@ -156,31 +183,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="povrayLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="povrayExecutable"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="povrayExecutableBrowse">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Color Configuration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Minifig Settings:</string>
|
||||
<property name="buddy">
|
||||
<cstring>ColorConfigEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -198,6 +207,16 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Minifig Settings:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>MinifigSettingsEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="MinifigSettingsLayout">
|
||||
<item>
|
||||
|
@ -212,6 +231,54 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="povrayLabel">
|
||||
<property name="text">
|
||||
<string>PO&V-Ray Executable:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>povrayExecutable</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="povrayLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="povrayExecutable"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="povrayExecutableBrowse">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>&LGEO Library:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lgeoPath</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lgeoPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="lgeoPathBrowse">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1097,8 +1164,9 @@
|
|||
<tabstop>povrayExecutableBrowse</tabstop>
|
||||
<tabstop>lgeoPath</tabstop>
|
||||
<tabstop>lgeoPathBrowse</tabstop>
|
||||
<tabstop>authorName</tabstop>
|
||||
<tabstop>Language</tabstop>
|
||||
<tabstop>checkForUpdates</tabstop>
|
||||
<tabstop>authorName</tabstop>
|
||||
<tabstop>fixedDirectionKeys</tabstop>
|
||||
<tabstop>autoLoadMostRecent</tabstop>
|
||||
<tabstop>antiAliasing</tabstop>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "lc_application.h"
|
||||
#include "lc_qupdatedialog.h"
|
||||
#include "lc_mainwindow.h"
|
||||
#include "lc_profile.h"
|
||||
#include <QApplication>
|
||||
#include <locale.h>
|
||||
|
||||
|
@ -125,24 +126,30 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
lcApplication Application(argc, argv);
|
||||
|
||||
QString Language = lcGetProfileString(LC_PROFILE_LANGUAGE);
|
||||
QLocale Locale;
|
||||
|
||||
if (!Language.isEmpty())
|
||||
Locale = QLocale(Language);
|
||||
|
||||
QTranslator QtTranslator;
|
||||
if (QtTranslator.load(QLocale::system(), "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
if (QtTranslator.load(Locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
Application.installTranslator(&QtTranslator);
|
||||
#ifdef Q_OS_WIN
|
||||
else if (QtTranslator.load(QLocale::system(), "qt", "_", qApp->applicationDirPath() + "/translations"))
|
||||
else if (QtTranslator.load(Locale, "qt", "_", qApp->applicationDirPath() + "/translations"))
|
||||
Application.installTranslator(&QtTranslator);
|
||||
#endif
|
||||
|
||||
QTranslator QtBaseTranslator;
|
||||
if (QtBaseTranslator.load("qtbase_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
if (QtBaseTranslator.load("qtbase_" + Locale.name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
Application.installTranslator(&QtBaseTranslator);
|
||||
#ifdef Q_OS_WIN
|
||||
else if (QtBaseTranslator.load("qtbase_" + QLocale::system().name(), qApp->applicationDirPath() + "/translations"))
|
||||
else if (QtBaseTranslator.load("qtbase_" + Locale.name(), qApp->applicationDirPath() + "/translations"))
|
||||
Application.installTranslator(&QtBaseTranslator);
|
||||
#endif
|
||||
|
||||
QTranslator Translator;
|
||||
if (Translator.load("leocad_" + QLocale::system().name(), ":/resources"))
|
||||
if (Translator.load("leocad_" + Locale.name(), ":/resources"))
|
||||
Application.installTranslator(&Translator);
|
||||
|
||||
qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
|
||||
|
|
Loading…
Reference in a new issue