From 9ce0432cffec7e45b876f4f173a570c62d9e9b60 Mon Sep 17 00:00:00 2001 From: sniperbeamer Date: Wed, 18 Mar 2009 12:50:30 +0000 Subject: [PATCH] Fix crash when changing language (using Qt 4.3) git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@290 b624d157-de02-0410-bad0-e51aec6abb33 --- src/dialogs/SettingsDlg.cpp | 18 +++++++++++++++--- src/dialogs/SettingsDlg.h | 1 + src/forms/SettingsDlg.ui | 10 ---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/dialogs/SettingsDlg.cpp b/src/dialogs/SettingsDlg.cpp index f04674e..a8d59a4 100644 --- a/src/dialogs/SettingsDlg.cpp +++ b/src/dialogs/SettingsDlg.cpp @@ -130,10 +130,10 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog) //Language translations = getAllTranslations(); + initLanguageList(); QString currentLang = config->language(); bool foundCurrent = false; for (int i=0; iaddItem(translations[i].nameLong); if (translations[i].nameCode==currentLang){ listSelectLanguage->setCurrentRow(i+2); foundCurrent = true; @@ -272,7 +272,8 @@ void CSettingsDlg::apply(){ if (config->language() != oldLang){ installTranslator(); retranslateUi(this); - OnSelectLanguage(langIndex); + initLanguageList(); + listSelectLanguage->setCurrentRow(langIndex); } //Security @@ -282,7 +283,7 @@ void CSettingsDlg::apply(){ config->setLockOnMinimize(CheckBox_LockMinimize->isChecked()); config->setLockOnInactivity(CheckBox_InactivityLock->isChecked()); config->setLockAfterSec(SpinBox_InacitivtyTime->value()); - + //Features //config->setFeatureBookmarks(CheckBox_FeatureBookmarks->isChecked()); @@ -398,6 +399,9 @@ void CSettingsDlg::OnBackupDeleteChange(){ } void CSettingsDlg::OnSelectLanguage(int index){ + if (index == -1) + return; + if (index==0){ labelLang->clear(); labelAuthor->clear(); @@ -415,6 +419,14 @@ void CSettingsDlg::OnSelectLanguage(int index){ } } +void CSettingsDlg::initLanguageList() { + listSelectLanguage->clear(); // completely rebuild the list because of a bug in Qt 4.3 + listSelectLanguage->addItem(tr("System Language")); + listSelectLanguage->addItem("English (United States)"); // Don't translate this string + for (int i=0; iaddItem(translations[i].nameLong); +} + #ifdef GLOBAL_AUTOTYPE void CSettingsDlg::resetGlobalShortcut(){ autoType->unregisterGlobalShortcut(); diff --git a/src/dialogs/SettingsDlg.h b/src/dialogs/SettingsDlg.h index 64aa627..e3f7cb7 100644 --- a/src/dialogs/SettingsDlg.h +++ b/src/dialogs/SettingsDlg.h @@ -58,6 +58,7 @@ class CSettingsDlg : public QDialog, private Ui_SettingsDialog private: virtual void paintEvent(QPaintEvent*); virtual void resizeEvent(QResizeEvent*); + void initLanguageList(); void apply(); QColor color1,color2,textcolor; QPixmap BannerPixmap; diff --git a/src/forms/SettingsDlg.ui b/src/forms/SettingsDlg.ui index ae76fe5..eea934f 100644 --- a/src/forms/SettingsDlg.ui +++ b/src/forms/SettingsDlg.ui @@ -832,16 +832,6 @@ QListView::item { QAbstractItemView::SelectRows - - - System Language - - - - - English - -