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
master
sniperbeamer 16 years ago
parent e3dcd73b89
commit 9ce0432cff
  1. 18
      src/dialogs/SettingsDlg.cpp
  2. 1
      src/dialogs/SettingsDlg.h
  3. 10
      src/forms/SettingsDlg.ui

@ -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; i<translations.size(); i++){
listSelectLanguage->addItem(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; i<translations.size(); i++)
listSelectLanguage->addItem(translations[i].nameLong);
}
#ifdef GLOBAL_AUTOTYPE
void CSettingsDlg::resetGlobalShortcut(){
autoType->unregisterGlobalShortcut();

@ -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;

@ -832,16 +832,6 @@ QListView::item {
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectRows</enum>
</property>
<item>
<property name="text" >
<string>System Language</string>
</property>
</item>
<item>
<property name="text" >
<string>English</string>
</property>
</item>
</widget>
</item>
<item>