-rw-r--r-- | noncore/settings/language/language.cpp | 124 |
1 files changed, 67 insertions, 57 deletions
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp index 397d372..5c4284b 100644 --- a/noncore/settings/language/language.cpp +++ b/noncore/settings/language/language.cpp | |||
@@ -60,33 +60,38 @@ | |||
60 | 60 | ||
61 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) | 61 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) |
62 | : LanguageSettingsBase( parent, name, TRUE, fl ) | 62 | : LanguageSettingsBase( parent, name, TRUE, fl ) |
63 | { | 63 | { |
64 | if ( FontManager::hasUnicodeFont() ) | 64 | if ( FontManager::hasUnicodeFont() ) |
65 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); | 65 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); |
66 | 66 | ||
67 | QString tfn = QPEApplication::qpeDir()+"/i18n/"; | 67 | |
68 | QDir langDir = tfn; | 68 | QString tfn = QPEApplication::qpeDir() + "/i18n/"; |
69 | QStringList list = langDir.entryList("*", QDir::Dirs ); | 69 | QDir langDir = tfn; |
70 | 70 | QStringList list = langDir.entryList("*", QDir::Dirs ); | |
71 | QStringList::Iterator it; | 71 | |
72 | 72 | QStringList::Iterator it; | |
73 | for( it = list.begin(); it != list.end(); ++it ) { | 73 | |
74 | QString name = (*it); | 74 | for ( it = list.begin(); it != list.end(); ++it ) { |
75 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); | 75 | QString name = (*it); |
76 | if( desktopFile.exists() ) { | 76 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); |
77 | langAvail.append(name); | 77 | if ( desktopFile.exists() ) { |
78 | Config conf( desktopFile.filePath(), Config::File ); | 78 | langAvail.append(name); |
79 | QString langName = conf.readEntry( "Name" ); | 79 | Config conf( desktopFile.filePath(), Config::File ); |
80 | QString ownName = conf.readEntryDirect( "Name["+name+"]" ); | 80 | QString langName = conf.readEntry( "Name" ); |
81 | if ( ownName.isEmpty() ) | 81 | QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); |
82 | ownName = conf.readEntryDirect( "Name" ); | 82 | if ( ownName.isEmpty() ) |
83 | if ( !ownName.isEmpty() && ownName != langName ) | 83 | ownName = conf.readEntryDirect( "Name" ); |
84 | langName = langName + " [" + ownName + "]"; | 84 | if ( !ownName.isEmpty() && ownName != langName ) |
85 | languages->insertItem( langName ); | 85 | langName = langName + " [" + ownName + "]"; |
86 | 86 | languages->insertItem( langName ); | |
87 | |||
88 | } | ||
87 | } | 89 | } |
88 | } | 90 | if ( langAvail. find ( "en" ) == -1 ) { |
89 | 91 | langAvail. prepend ( "" ); // no tr | |
90 | dl = new QPEDialogListener(this); | 92 | languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); |
91 | reset(); | 93 | } |
94 | |||
95 | dl = new QPEDialogListener(this); | ||
96 | reset(); | ||
92 | } | 97 | } |
@@ -94,4 +99,3 @@ LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags f | |||
94 | LanguageSettings::~LanguageSettings() | 99 | LanguageSettings::~LanguageSettings() |
95 | { | 100 | {} |
96 | } | ||
97 | 101 | ||
@@ -99,4 +103,4 @@ void LanguageSettings::accept() | |||
99 | { | 103 | { |
100 | applyLanguage(); | 104 | applyLanguage(); |
101 | QDialog::accept(); | 105 | QDialog::accept(); |
102 | } | 106 | } |
@@ -105,4 +109,3 @@ void LanguageSettings::applyLanguage() | |||
105 | { | 109 | { |
106 | QString lang = langAvail.at( languages->currentItem() ); | 110 | setLanguage ( langAvail. at ( languages-> currentItem ( ))); |
107 | setLanguage( lang ); | ||
108 | } | 111 | } |
@@ -112,4 +115,4 @@ void LanguageSettings::reject() | |||
112 | { | 115 | { |
113 | reset(); | 116 | reset(); |
114 | QDialog::reject(); | 117 | QDialog::reject(); |
115 | } | 118 | } |
@@ -118,10 +121,12 @@ void LanguageSettings::reset() | |||
118 | { | 121 | { |
119 | QString l = getenv("LANG"); | 122 | QString l = getenv("LANG"); |
120 | Config config("language"); | 123 | Config config("locale"); |
121 | l = config.readEntry( "Language", l ); | 124 | config.setGroup("Language"); |
122 | if(l.isEmpty()) l = "en"; | 125 | l = config.readEntry( "Language", l ); |
123 | actualLanguage = l; | 126 | if (l.isEmpty()) |
124 | 127 | l = "en"; | |
125 | int n = langAvail.find( l ); | 128 | actualLanguage = l; |
126 | languages->setCurrentItem( n ); | 129 | |
130 | int n = langAvail.find( l ); | ||
131 | languages->setCurrentItem( n ); | ||
127 | } | 132 | } |
@@ -132,19 +137,24 @@ void LanguageSettings::setLanguage(const QString& lang) | |||
132 | { | 137 | { |
133 | if( lang != actualLanguage ) { | 138 | if ( lang != actualLanguage ) { |
134 | Config config("locale"); | 139 | Config config("locale"); |
135 | config.setGroup( "Language" ); | 140 | config.setGroup( "Language" ); |
136 | config.writeEntry( "Language", lang ); | 141 | if ( lang. isEmpty ( )) |
137 | config.write(); | 142 | config. removeEntry ( "Language" ); |
138 | 143 | else | |
144 | config.writeEntry( "Language", lang ); | ||
145 | config.write(); | ||
146 | |||
139 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 147 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
140 | QCopEnvelope e("QPE/System","language(QString)"); | 148 | |
141 | e << lang; | 149 | QCopEnvelope e("QPE/System", "language(QString)"); |
150 | e << lang; | ||
142 | #endif | 151 | #endif |
143 | } | 152 | |
153 | } | ||
144 | } | 154 | } |
145 | 155 | ||
146 | void LanguageSettings::done(int r) | 156 | void LanguageSettings::done(int r) |
147 | { | 157 | { |
148 | QDialog::done(r); | 158 | QDialog::done(r); |
149 | close(); | 159 | close(); |
150 | } | 160 | } |