Fix a couple of language change issues
When changing the language in the preferences dialog without closing it then a few things are not re-translated
This commit is contained in:
@@ -328,19 +328,7 @@ void DlgSettingsGeneral::loadSettings()
|
||||
if (model)
|
||||
model->sort(0);
|
||||
|
||||
int current = getMainWindow()->iconSize().width();
|
||||
current = hGrp->GetInt("ToolbarIconSize", current);
|
||||
ui->toolbarIconSize->clear();
|
||||
ui->toolbarIconSize->addItem(tr("Small (%1px)").arg(16), QVariant((int)16));
|
||||
ui->toolbarIconSize->addItem(tr("Medium (%1px)").arg(24), QVariant((int)24));
|
||||
ui->toolbarIconSize->addItem(tr("Large (%1px)").arg(32), QVariant((int)32));
|
||||
ui->toolbarIconSize->addItem(tr("Extra large (%1px)").arg(48), QVariant((int)48));
|
||||
index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
if (index < 0) {
|
||||
ui->toolbarIconSize->addItem(tr("Custom (%1px)").arg(current), QVariant((int)current));
|
||||
index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
}
|
||||
ui->toolbarIconSize->setCurrentIndex(index);
|
||||
addIconSizes(getCurrentIconSize());
|
||||
|
||||
//TreeMode combobox setup.
|
||||
loadDockWindowVisibility();
|
||||
@@ -451,14 +439,68 @@ void DlgSettingsGeneral::loadThemes()
|
||||
}
|
||||
}
|
||||
|
||||
int DlgSettingsGeneral::getCurrentIconSize() const
|
||||
{
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
int current = getMainWindow()->iconSize().width();
|
||||
return hGrp->GetInt("ToolbarIconSize", current);
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::addIconSizes(int current)
|
||||
{
|
||||
ui->toolbarIconSize->clear();
|
||||
|
||||
QList<int> sizes{16, 24, 32, 48};
|
||||
if (!sizes.contains(current)) {
|
||||
sizes.append(current);
|
||||
}
|
||||
|
||||
for (int size : sizes) {
|
||||
ui->toolbarIconSize->addItem(QString(), QVariant(size));
|
||||
}
|
||||
|
||||
int index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
ui->toolbarIconSize->setCurrentIndex(index);
|
||||
translateIconSizes();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::translateIconSizes()
|
||||
{
|
||||
auto getSize = [this](int index) {
|
||||
return ui->toolbarIconSize->itemData(index).toInt();
|
||||
};
|
||||
|
||||
QStringList sizes;
|
||||
sizes << tr("Small (%1px)").arg(getSize(0));
|
||||
sizes << tr("Medium (%1px)").arg(getSize(1));
|
||||
sizes << tr("Large (%1px)").arg(getSize(2));
|
||||
sizes << tr("Extra large (%1px)").arg(getSize(3));
|
||||
if (ui->toolbarIconSize->count() > 4) {
|
||||
sizes << tr("Custom (%1px)").arg(getSize(4));
|
||||
}
|
||||
|
||||
for (int index = 0; index < sizes.size(); index++) {
|
||||
ui->toolbarIconSize->setItemText(index, sizes[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::retranslateUnits()
|
||||
{
|
||||
int num = ui->comboBox_UnitSystem->count();
|
||||
for (int i = 0; i < num; i++) {
|
||||
QString item = Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i));
|
||||
ui->comboBox_UnitSystem->setItemText(i, item);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
translateIconSizes();
|
||||
retranslateUnits();
|
||||
int index = ui->UseLocaleFormatting->currentIndex();
|
||||
int index2 = ui->comboBox_UnitSystem->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
ui->UseLocaleFormatting->setCurrentIndex(index);
|
||||
ui->comboBox_UnitSystem->setCurrentIndex(index2);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(event);
|
||||
@@ -715,4 +757,4 @@ void DlgSettingsGeneral::attachObserver()
|
||||
handlers.addHandler(ParamKey(hDockWindows->GetGroup("DAGView"), "Enabled"), applyDockWidget);
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsGeneral.cpp"
|
||||
#include "moc_DlgSettingsGeneral.cpp"
|
||||
|
||||
@@ -84,6 +84,10 @@ private:
|
||||
bool setLanguage(); //Returns true if language has been changed
|
||||
void setNumberLocale(bool force = false);
|
||||
void setDecimalPointConversion(bool on);
|
||||
void retranslateUnits();
|
||||
int getCurrentIconSize() const;
|
||||
void addIconSizes(int current);
|
||||
void translateIconSizes();
|
||||
|
||||
private:
|
||||
int localeIndex;
|
||||
|
||||
@@ -166,29 +166,8 @@ void DlgSettingsNavigation::loadSettings()
|
||||
bool useNavigationAnimations = hGrp->GetBool("UseNavigationAnimations", true);
|
||||
ui->groupBoxAnimations->setChecked(useNavigationAnimations);
|
||||
|
||||
ui->comboNewDocView->addItem(tr("Isometric"), QByteArray("Isometric"));
|
||||
ui->comboNewDocView->addItem(tr("Dimetric"), QByteArray("Dimetric"));
|
||||
ui->comboNewDocView->addItem(tr("Trimetric"), QByteArray("Trimetric"));
|
||||
ui->comboNewDocView->addItem(tr("Top"), QByteArray("Top"));
|
||||
ui->comboNewDocView->addItem(tr("Front"), QByteArray("Front"));
|
||||
ui->comboNewDocView->addItem(tr("Left"), QByteArray("Left"));
|
||||
ui->comboNewDocView->addItem(tr("Right"), QByteArray("Right"));
|
||||
ui->comboNewDocView->addItem(tr("Rear"), QByteArray("Rear"));
|
||||
ui->comboNewDocView->addItem(tr("Bottom"), QByteArray("Bottom"));
|
||||
ui->comboNewDocView->addItem(tr("Custom"), QByteArray("Custom"));
|
||||
std::string camera = hGrp->GetASCII("NewDocumentCameraOrientation", "Trimetric");
|
||||
index = ui->comboNewDocView->findData(QByteArray(camera.c_str()));
|
||||
if (index > -1) ui->comboNewDocView->setCurrentIndex(index);
|
||||
if (camera == "Custom") {
|
||||
ParameterGrp::handle hCustom = hGrp->GetGroup("Custom");
|
||||
q0 = hCustom->GetFloat("Q0", q0);
|
||||
q1 = hCustom->GetFloat("Q1", q1);
|
||||
q2 = hCustom->GetFloat("Q2", q2);
|
||||
q3 = hCustom->GetFloat("Q3", q3);
|
||||
}
|
||||
addOrientations();
|
||||
|
||||
connect(ui->comboNewDocView, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsNavigation::onNewDocViewChanged);
|
||||
connect(ui->mouseButton, &QPushButton::clicked,
|
||||
this, &DlgSettingsNavigation::onMouseButtonClicked);
|
||||
|
||||
@@ -210,6 +189,50 @@ void DlgSettingsNavigation::loadSettings()
|
||||
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::addOrientations()
|
||||
{
|
||||
ui->comboNewDocView->addItem(tr("Isometric"), QByteArray("Isometric"));
|
||||
ui->comboNewDocView->addItem(tr("Dimetric"), QByteArray("Dimetric"));
|
||||
ui->comboNewDocView->addItem(tr("Trimetric"), QByteArray("Trimetric"));
|
||||
ui->comboNewDocView->addItem(tr("Top"), QByteArray("Top"));
|
||||
ui->comboNewDocView->addItem(tr("Front"), QByteArray("Front"));
|
||||
ui->comboNewDocView->addItem(tr("Left"), QByteArray("Left"));
|
||||
ui->comboNewDocView->addItem(tr("Right"), QByteArray("Right"));
|
||||
ui->comboNewDocView->addItem(tr("Rear"), QByteArray("Rear"));
|
||||
ui->comboNewDocView->addItem(tr("Bottom"), QByteArray("Bottom"));
|
||||
ui->comboNewDocView->addItem(tr("Custom"), QByteArray("Custom"));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
std::string camera = hGrp->GetASCII("NewDocumentCameraOrientation", "Trimetric");
|
||||
int index = ui->comboNewDocView->findData(QByteArray(camera.c_str()));
|
||||
if (index > -1) ui->comboNewDocView->setCurrentIndex(index);
|
||||
if (camera == "Custom") {
|
||||
ParameterGrp::handle hCustom = hGrp->GetGroup("Custom");
|
||||
q0 = hCustom->GetFloat("Q0", q0);
|
||||
q1 = hCustom->GetFloat("Q1", q1);
|
||||
q2 = hCustom->GetFloat("Q2", q2);
|
||||
q3 = hCustom->GetFloat("Q3", q3);
|
||||
}
|
||||
|
||||
connect(ui->comboNewDocView, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsNavigation::onNewDocViewChanged);
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::translateOrientations()
|
||||
{
|
||||
ui->comboNewDocView->setItemText(0, tr("Isometric"));
|
||||
ui->comboNewDocView->setItemText(1, tr("Dimetric"));
|
||||
ui->comboNewDocView->setItemText(2, tr("Trimetric"));
|
||||
ui->comboNewDocView->setItemText(3, tr("Top"));
|
||||
ui->comboNewDocView->setItemText(4, tr("Front"));
|
||||
ui->comboNewDocView->setItemText(5, tr("Left"));
|
||||
ui->comboNewDocView->setItemText(6, tr("Right"));
|
||||
ui->comboNewDocView->setItemText(7, tr("Rear"));
|
||||
ui->comboNewDocView->setItemText(8, tr("Bottom"));
|
||||
ui->comboNewDocView->setItemText(9, tr("Custom"));
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
@@ -282,6 +305,7 @@ void DlgSettingsNavigation::changeEvent(QEvent *e)
|
||||
int corner = ui->naviCubeCorner->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
retranslate();
|
||||
translateOrientations();
|
||||
ui->comboNavigationStyle->setCurrentIndex(navigation);
|
||||
ui->comboOrbitStyle->setCurrentIndex(orbit);
|
||||
ui->naviCubeCorner->setCurrentIndex(corner);
|
||||
|
||||
@@ -58,6 +58,8 @@ private:
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void retranslate();
|
||||
void addOrientations();
|
||||
void translateOrientations();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsNavigation> ui;
|
||||
|
||||
@@ -487,6 +487,7 @@ void DlgSettingsWorkbenchesImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
translateWorkbenchSelector();
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
@@ -534,6 +535,16 @@ void DlgSettingsWorkbenchesImp::loadWorkbenchSelector()
|
||||
ui->WorkbenchSelectorItem->setCurrentIndex(itemStyleIndex);
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::translateWorkbenchSelector()
|
||||
{
|
||||
ui->WorkbenchSelectorType->setItemText(0, tr("ComboBox"));
|
||||
ui->WorkbenchSelectorType->setItemText(1, tr("TabBar"));
|
||||
|
||||
ui->WorkbenchSelectorItem->setItemText(0, tr("Icon & Text"));
|
||||
ui->WorkbenchSelectorItem->setItemText(1, tr("Icon"));
|
||||
ui->WorkbenchSelectorItem->setItemText(2, tr("Text"));
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::wbToggled(const QString& wbName, bool enabled)
|
||||
{
|
||||
setStartWorkbenchComboItems();
|
||||
|
||||
@@ -71,6 +71,7 @@ private:
|
||||
|
||||
void saveWorkbenchSelector();
|
||||
void loadWorkbenchSelector();
|
||||
void translateWorkbenchSelector();
|
||||
|
||||
|
||||
std::vector<std::string> _backgroundAutoloadedModules;
|
||||
|
||||
Reference in New Issue
Block a user